package com.fx.eduservice.controller;


import com.fx.commonuntils.ReturnMessage;
import com.fx.eduservice.entity.vo.EduSubject;
import com.fx.eduservice.mapper.EduSubjectMapper;
import com.fx.eduservice.response.subject.RecursionSubject;
import com.fx.eduservice.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-11-05
 */
@Api(description = "分类管理系统")
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Slf4j
@CrossOrigin//解决跨域问题
@RequestMapping("/eduservice/eduSubject")
public class EduSubjectController {

    final private EduSubjectService eduSubjectService;

    @ApiOperation(value = "上传excel课程分类")
    @PostMapping("/addSubject")
    public ReturnMessage<Object> addSubject(@ApiParam(name = "addSubject", value = "分类文件上传", required = true)
                                            @RequestParam("addSubject") MultipartFile multipartFile) {
        //上传过来excel文件

        return eduSubjectService.saveSubject(multipartFile, eduSubjectService);
    }


    @ApiOperation(value = "返回树状课程分类列表")
    @GetMapping("/getSubjectTree")
    public ReturnMessage<Object> getSubjectTree() {
        //上传过来excel文件

        return eduSubjectService.getSubjectTree();
    }


    @ApiOperation(value = "根据id递归查询课程分类列表")
    @GetMapping("/getSubjectTreeByid")
    public ReturnMessage<Object> getSubjectTreeById(EduSubject eduSubject) {
        //上传过来excel文件

        return eduSubjectService.getSubjectTreeById(eduSubject);
    }


}

